package cm.util.action.list;

import cm.util.service.GenericService;
import cm.util.service.GenericServiceImpl;

/**
 * 
 * @author 苏玮
 *
 * 2010-11-29
 *
 * @param <E>
 * @param <PK>
 */
public class GenericListActionSupport<E> extends ListActionSupport<E>{

	/**
	 * 
	 */
	private static final long serialVersionUID = 8555589202087459230L;
	
	GenericService<E> service;
	
	/**
	 * 根据实体类类对象构造Action
	 * 
	 * @param entityClass
	 * 			实体类类对象
	 */
	public GenericListActionSupport(Class<E> entityClass){
		service=new GenericServiceImpl<E>(entityClass);
	}
	
	/**
	 * 根据实体类对象以及service方法构造Action
	 * @param entityClass
	 * @param service
	 */
	public GenericListActionSupport(Class<E> entityClass,GenericService<E> service){
		this.service=service;
	}
	
	/**
	 * 根据实体类类类名构造Action
	 * @param entityClassName
	 * 			实体类类名
	 */
	public GenericListActionSupport(String entityClassName){
		service=new GenericServiceImpl<E>(entityClassName);
	}
	@Override
	protected String findAll() {
		totalRows=service.sizeAll();
		initPageProperties();
		
		
		
		list=service.findAll(currentPage, pageSize);
		return FIND_ALL_SUCCESS;
	}

}
